//后台上传使用的处理js
$(function(){
	var sp=$('article>p');
	var lines=[];
	for(var i=0;i<sp.length;i++)
	{
		lines.push(sp[i].innerText);
	}
	var all=[];
	var every=[];
	var spaceReg=/^\s*$/;
	var allp=[];
	for (var i = 0; i < lines.length; i++)
	{
		if (!spaceReg.exec(lines[i])) {
			allp.push(lines[i]);
			every=lines[i].split(/[.?!](?=\s)/);
			all.push(every);
		}
	}
	for(var i=0;i<all.length;i++){
		var add='';
		var length=0;
		for(var j=0;j<all[i].length-1;j++){
			length=length+all[i][j].length;
			all[i][j]=all[i][j]+allp[i].substr(length+j,1);
		}
	}

	var addhtml='';
	var n=0;
	for (var i = 0; i < all.length; i++) {
			addhtml=addhtml+'<p id=paragraph'+(i+1)+' class="article">';
		for(var j=0;j<all[i].length;j++){
			n++;
			addhtml=addhtml+'<span id=lines'+n+'>'+all[i][j]+'</span>';
		}
		addhtml=addhtml+'</p>';
	}
	$('article').html(addhtml);
	$('span').dblclick(function(){
		if($(this).hasClass("btn-success the-key-line"))
		{
			$(this).removeClass("btn-success the-key-line");
		}
		else
		{
			$(this).addClass("btn-success the-key-line");
		}
	}).hover(function(){
		$(this).addClass("bg-info border-radius");
	},function(){
		$(this).removeClass("bg-info border-radius");
	});
    
    $("#submit").click(function(){
        $("span").each(function(){
            $(this).removeClass("btn-success");
        })
        var allart=$(".details>article").html();
        $("#article").val(allart);
    });
    var editor = new MediumEditor('.article',
    {
        toolbar: {
            buttons: ['bold', 'italic', 'underline']
        }
    });



});
